from dataclasses import dataclass, field
from typing import Self

from poker_bot.core.models.enums.user import LangCode, UserRole


@dataclass
class UserEntity:
    id: int | None = None
    role: UserRole | None = None
    telegram_id: int | None = None
    selected_account_id: int | None = None
    username: str | None = None
    # referrals: list["UserEntity"] | None = field(default_factory=list)
    referrer_id: int | None = None
    is_subscribed: bool = field(default=False)
    lang_code: LangCode = field(default=LangCode.ru)

    @classmethod
    def create(cls, telegram_id: int, username: str) -> Self:
        user = cls(telegram_id=telegram_id, username=username)
        return user

    def update_is_subscribed(self, is_subscribed: bool):
        self.is_subscribed = is_subscribed

    def update_selected_account_id(self, selected_account_id: int):
        self.selected_account_id = selected_account_id

    def change_lang(self, lang_code: LangCode):
        self.lang_code = lang_code
